package org.yray.k8s;

import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.JSON;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.apis.CustomObjectsApi;
import io.kubernetes.client.openapi.models.V1Pod;
import io.kubernetes.client.openapi.models.V1PodList;
import io.kubernetes.client.util.ClientBuilder;
import io.kubernetes.client.util.credentials.AccessTokenAuthentication;

public class CustomObjectsApiDemo {
    public static void main(String[] args) throws Exception {
        // 创建Kubernetes客户端
        ApiClient client = new ClientBuilder().setBasePath("https://192.168.127.129:6443").setVerifyingSsl(false)
                .setAuthentication(new AccessTokenAuthentication("6ls2i7.i4cqpmjl0tv92mml")).build();
        Configuration.setDefaultApiClient(client);
        CustomObjectsApi apiInstance = new CustomObjectsApi();
        String group = "flycloud.cn";
        String version = "v1";
        String plural = "clusters";
        String pretty = "ture";
        try {
            Object result = apiInstance.listClusterCustomObject(group,version,plural,pretty,null,null,null,null,null,null,null,null,null);
            //String listCluster = JSON.toJSONString(result);
            //System.out.println(listCluster);
        } catch (ApiException e) {
            System.err.println("Exception when calling CustomObjectsApi#listClusterCustomObject");
            e.printStackTrace();
        }
    }
}